define([
	'app',
	'lodash',
	'services/TipsService',
	"resources/AddCompanyResource",
	"directives/addCompany/EditCompany",
	"directives/addCompany/CompanyCharge"
	
], function(app, _ ) {

	var deps = [ '$state', 'TipsService','AddCompanyResource' ];

	function directive($state, TipsService,AddCompanyResource) {
		return {
			templateUrl: 'views/conference/Company.html',
			replace: true,
			scope: {
				company: '=fcCompany'
			},
			link: function($scope) {

				$scope.changeCEditImage=function (flag){
					var carId =$scope.company.id;
					var image =document.getElementById("changeCEditImage"+carId);
					if(flag){
						image.src="images/edit2.png";
					}else{
						image.src="images/edit1.png";
					}
				};
				
				$scope.changeReChargeImage=function (flag){
					var carId =$scope.company.id;
					var image =document.getElementById("changeReChargeImage"+carId);
					if(flag){
						image.src="images/recharge2.png";
					}else{
						image.src="images/recharge1.png";
					}
				};
				
				$scope.changeDeleteImage=function (flag){
					var carId =$scope.company.id;
					var image =document.getElementById("changeDeleteImage"+carId);
					if(flag){
						image.src="images/delete2.png";
					}else{
						image.src="images/delete1.png";
					}
				};
				
				/*$scope.changeBorderColor=function (flag){
					var carId =$scope.company.id;
					var divObj =document.getElementById("border"+carId);
					if(flag){
						//divObj.style.borderColor="#00a8ff";
						//divObj.style.borderRadius="7px";
						divObj.style.borderColor="#00a8ff";
					}else{
						divObj.style.borderColor="#ffffff";
						divObj.style.borderRadius="7px";
					}
				};*/
				
				
				// 跳转到详情页面
				$scope.goToRecord =function (){
					$state.go("home.companyDetail", {
		                keyId: $scope.company.companyCode
		            });
				};
				
				
				/**
				 * 删除card
				 */
				$scope.deleteCar = function (){
					var carId =$scope.company.id;
					AddCompanyResource.deleteCar(carId).success(function(result){
						$scope.$bus.publish({
							company: 'company',
							topic: 'remove',
							data: $scope.company.id
						});
		            });
				};
				
				/*$scope.getImageId1=function getImageId1(id){
					return 'changeCEditImage'+id;
				};
				$scope.getImageId2=function getImageId2(id){
					return 'changeReChargeImage'+id;
				};
				
				$scope.getImageId3=function getImageId3(id){
					return 'changeDeleteImage'+id;
				};*/
			}
		};
	}

	directive.$inject = deps;
	return app.lazy.directive('fcCompany', directive);
});